package com.dindang.propertyfee.mvp.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.constraint.Group;
import android.support.v7.widget.RecyclerView;
import android.widget.ImageView;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.dindang.propertyfee.R;
import com.dindang.propertyfee.di.component.DaggerReceivableDetailComponent;
import com.dindang.propertyfee.di.module.ReceivableDetailModule;
import com.dindang.propertyfee.mvp.contract.ReceivableDetailContract;
import com.dindang.propertyfee.mvp.presenter.ReceivableDetailPresenter;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
import com.longxi.gamer_base.widget.EmptyLayout;


import static com.jess.arms.utils.Preconditions.checkNotNull;

@Route(path = "/propertyfee/activity/ReceivableDetailActivity")
public class ReceivableDetailActivity extends BaseActivity<ReceivableDetailPresenter> implements ReceivableDetailContract.View {

    ImageView mIvBack;
    TextView mTvTitle;
    TextView mTvCustomerName;
    TextView mTvAddress;
    ImageView mIvPhone;
    RecyclerView mListview;

    ImageView mSwitchChecked;
    TextView mTvTotalPrice;
    TextView mTvCommit;
    EmptyLayout mEmptylayout;
    Group mGroupFunction;

    @Override
    public void setupActivityComponent(@NonNull AppComponent appComponent) {
        DaggerReceivableDetailComponent //如找不到该类,请编译一下项目
                .builder()
                .appComponent(appComponent)
                .receivableDetailModule(new ReceivableDetailModule(this))
                .build()
                .inject(this);
    }

    @Override
    public int initView(@Nullable Bundle savedInstanceState) {
        return R.layout.propertyfee_activity_receivable_detail; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {
        mIvBack = findViewById(R.id.propertyfee_iv_back);
        mTvTitle = findViewById(R.id.propertyfee_tv_title);
        mTvCustomerName = findViewById(R.id.propertyfee_tv_customer_name);
        mTvAddress = findViewById(R.id.propertyfee_tv_address);
        mIvPhone = findViewById(R.id.propertyfee_iv_phone);
        mListview = findViewById(R.id.propertyfee_listview);
        mSwitchChecked = findViewById(R.id.propertyfee_switchChecked);
        mTvTotalPrice = findViewById(R.id.propertyfee_tv_total_price);
        mTvCommit = findViewById(R.id.propertyfee_tv_commit);
        mEmptylayout = findViewById(R.id.propertyfee_emptylayout);
        mGroupFunction = findViewById(R.id.propertyfee_group_function);
        mTvTitle.setText("应收明细");
        mIvBack.setOnClickListener(v -> finish());
        mIvPhone.setOnClickListener(v -> mPresenter.toPlayPhone());
        mPresenter.init();
    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void showMessage(@NonNull String message) {
        checkNotNull(message);
        ArmsUtils.snackbarText(message);
    }

    @Override
    public void launchActivity(@NonNull Intent intent) {
        checkNotNull(intent);
        ArmsUtils.startActivity(intent);
    }

    @Override
    public void killMyself() {
        finish();
    }

    @Override
    public TextView getTvCustomerName() {
        return mTvCustomerName;
    }

    @Override
    public TextView getTvAddress() {
        return mTvAddress;
    }

    @Override
    public RecyclerView getListview() {
        return mListview;
    }

    @Override
    public ImageView getSwitchChecked() {
        return mSwitchChecked;
    }

    @Override
    public TextView getTvTotalPrice() {
        return mTvTotalPrice;
    }

    @Override
    public TextView getTvCommit() {
        return mTvCommit;
    }

    @Override
    public Group getGroupFunction() {
        return mGroupFunction;
    }

    @Override
    public EmptyLayout getEmptyLayout() {
        return mEmptylayout;
    }

    @Override
    public BaseActivity getActivity() {
        return this;
    }

}
